package cn.hinglo.gameclaw.client.service;

import cn.hinglo.gameclaw.client.dao.OrderClientDao;
import cn.hinglo.gameclaw.data.entity.Result;
import cn.hinglo.gameclaw.data.utils.LogisticsUtils;
import cn.hinglo.gameclaw.data.utils.ResultUtils;
import cn.hinglo.gameclaw.user.bean.Morder;
import cn.hinglo.gameclaw.user.bean.Orders;
import cn.hutool.core.lang.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @createTime: 2018/1/4
 * @author: HingLo
 * @description: 订单管理服务
 */
@Service
public class OrderClientService {
    private final OrderClientDao orderClientDao;

    @Autowired
    public OrderClientService(OrderClientDao orderClientDao) {
        this.orderClientDao = orderClientDao;
    }

    /**
     * 订单查看
     *
     * @param id 用户编号
     * @return 返回值
     */
    public List<Orders> listOrderService(String id) {
        return orderClientDao.listUserIdDao(id);
    }

    /**
     * 充值即，。记录查询
     *
     * @param userId 用户编号
     * @return 充值记录
     */
    public List<Morder> listRechargeService(String userId) {
        Morder morder = new Morder().setStatus(true).setUserId(userId);
        return orderClientDao.select(morder);
    }

    /**
     * 物流信息查询
     *
     * @param id 物流编号
     * @return 物流信息
     */
    public Result findByIdGoodService(String id) {
        if (Validator.isNumber(id)) {
            return LogisticsUtils.getGoodsUtils(id);
        }
        return ResultUtils.error("订单编号不正确");


    }


}
